﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PokerClient.VisualDisp
{
	public partial class Raisebar : UserControl
	{
		String vMax, cBid;

		delegate void updateLables(String s);
		delegate void updateTextbox(String s);
		public Raisebar()
		{
			InitializeComponent();
			this.textBox1.Enabled = false;
			this.textBox1.Text = "0";
		}
		public Raisebar(String max) : this()
		{
			this.vMax = max;
			init();
		}

		private void init()
		{
			this.trackBar1.Maximum = Int32.Parse(vMax);
			this.label2.Text = vMax;
			this.trackBar1.TickFrequency = 500;
			//this.textBox1.Text = "0";
		}

		public void updateStat(String s)
		{
			if (this.label2.InvokeRequired)
			{
				updateLables ul = new updateLables(updateStat);
				this.label2.Invoke(ul, new object[] { s });
			}
			else
			{
				this.label2.Text = s;
				this.vMax = s;
			}
		}
		public void updateBid(String s)
		{
			if (this.textBox1.InvokeRequired)
			{
				updateTextbox ut = new updateTextbox(updateBid);
				this.textBox1.Invoke(ut, new object[] { s });
			}
			else
			{
				this.textBox1.Text = s;
			}
		}
		public void updateMax(String s)
		{
			try
			{
				this.vMax = s;
				int t = Int32.Parse(this.vMax);
				this.trackBar1.Maximum = t;
				this.updateStat(s);
			}
			catch (System.Exception ex)
			{
				Console.Write(ex.Message);
			}
		}

		private void trackBar1_Scroll(object sender, EventArgs e)
		{
			this.cBid = trackBar1.Value + "";
			this.textBox1.Text = this.cBid;
		}

	

		public String bid
		{
			get
			{
				return this.textBox1.Text;
			}
			set
			{
				this.updateBid(value);
			}
		}
	}
}
